package test6;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-02-19
 * Time: 23:01
 */
public class Test4 {
    public static volatile int flag = 0;
    public static void main(String[] args) {
        Thread thread1 = new Thread(()->{
            while(flag == 0){
//                try {
//                    Thread.sleep(1000);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
            }
            System.out.println("t1线程结束");
        });
        Thread thread2 = new Thread(()->{
            System.out.println("请输入flag的值");
            Scanner scanner = new Scanner(System.in);
            flag = scanner.nextInt();
        });
        thread1.start();
        thread2.start();
    }
}
